/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.service;

import com.ivanbiz.dao.PengajarDAO;
import com.ivanbiz.dao.impl.PengajarDAOImpl;
import com.ivanbiz.model.Pengajar;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.zkoss.zk.ui.util.GenericForwardComposer;

/**
 *
 * @author IW20149X
 */
public class PengajarServicebak extends GenericForwardComposer {

    PengajarDAO pengajarDAO = new PengajarDAOImpl();
    Pengajar pengajar = new Pengajar();

    public Pengajar getPengajar() {
        return pengajar;
    }

    public void setPengajar(Pengajar pengajar) {
        this.pengajar = pengajar;
    }

    public List<Pengajar> getListPengajar() {
        try {
            return pengajarDAO.getAll(Pengajar.class);
        } catch (Exception ex) {
            Logger.getLogger(PengajarServicebak.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    public void onClick$add() {
        try {
            pengajarDAO.save(pengajar);
        } catch (Exception ex) {
            Logger.getLogger(PengajarServicebak.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void onClick$update() {
        try {
            pengajarDAO.update(pengajar);
        } catch (Exception ex) {
            Logger.getLogger(PengajarServicebak.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void onClick$delete() {
        try {
            pengajarDAO.delete(pengajar);
        } catch (Exception ex) {
            Logger.getLogger(PengajarServicebak.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
